package com.atldy.commerce.account;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @version 1.0
 * @Author: lidongyang
 * @CreateTime: 2021-08-12 23:39
 * @Description： 用户地址单个信息
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("用户地址单个信息")
public class AddressItemVo {

    /**
     * 地址信息主键
     */
    @ApiModelProperty("地址信息主键")
    private Long id;

    /**
     * 用户 id
     */
    @ApiModelProperty("用户 id")
    private Long userId;

    /**
     * 用户名
     */
    @ApiModelProperty("用户名")
    private String username;

    /**
     * 电话号码
     */
    @ApiModelProperty("电话号码")
    private String phone;

    /**
     * 省
     */
    @ApiModelProperty("省")
    private String province;

    /**
     * 市
     */
    @ApiModelProperty("市")
    private String city;

    /**
     * 详细地址
     */
    @ApiModelProperty("详细地址")
    private String addressDetail;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    private Date createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty("更新时间")
    private Date updateTime;

    private static final long serialVersionUID = 1L;

    public AddressItemVo(Long id) {
        this.id = id;
    }

    /**
     * 将AddressItemVo转换为UserAddressInfo
     */
    public UserAddressInfo toUserAddressInfo() {
        UserAddressInfo info = new UserAddressInfo();
        info.setUsername(this.username);
        info.setPhone(this.phone);
        info.setProvince(this.province);
        info.setCity(this.city);
        info.setAddressDetail(this.addressDetail);
        return info;
    }
}